<?php

namespace App\Exports;


use App\Models\User\User;
use Illuminate\Support\Facades\Log;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\DataType;

class DemoExport extends CommonExport
{
    public function __construct(array $conditions=[],array $params=[]) {
        $this->instance = (new User());
        $this->conditions = $conditions;
        $this->params = $params;
        $this->title = [
            //TODO title
        ];


    }

    public function array(): array {
        $this->records = [$this->title];
        $cols = $this->getAllCols();

        foreach ($cols as $col) {
            //TODO 过滤要去掉的字段名
        }

        $this->records = $this->instance->getLst($this->conditions)->get($cols);

        return $this->records->toArray();
    }

    public function bindValue(Cell $cell, $value) {
        if (strlen($value) > 10) {
            $cell->setValueExplicit($value, DataType::TYPE_STRING);
            return true;
        }
        return parent::bindValue($cell, $value);
    }

}
